// D3D10Scene.h

#pragma once
#pragma managed(push, off)
#include <windows.h>

// C RunTime Header Files
#include <stdlib.h>
#include <stdio.h>
#include "D3D11.h"

#include "RBMain/RBCommon.h"
#include "RBMain/RBHandle.h"

#pragma managed(pop)

using namespace System;

class RBRenderTargetGroup;
class RBRenderPassFullScreen;
class RBTexture;

struct IDirect3D9Ex;
struct IDirect3DDevice9Ex;

class RBCamera;

struct rb_private_members;

namespace D3D10Scene {

    public enum class InputEvent
    {
        #define RBINPUTKEY(key, value) IK_##key = value,
        #define RBINPUTKEYASCII(key, value) RBINPUTKEY(key, value)
        #include "RBMain/RBInputKeys.inl"
        IK_COUNT
    };

    public ref class D3D9_Creator
    {
    public:
        D3D9_Creator();
        bool InitD3D9();

        IntPtr D3D9;
        IntPtr D3D9_Device;
    };


	public ref class D3D10TestScene
	{
	public:

        D3D10TestScene(IntPtr hWnd, int width, int height);
        void ChangeSize(int width, int height);

        IntPtr GetRenderTarget();
		IntPtr GetRenderTargetGI();

        void Render();
		void Release();
        void AddFile(System::String^ filename);

        void OnInput  (InputEvent event, bool down);
        void SetMousePos  (int x, int y);
        void SetCameraSpeed(float new_speed);

        void get_camera_pos(float& x, float& y, float& z);

        void create_gi();

        int get_visible_pixels();

    private:
		UINT WIDTH;
		UINT HEIGHT;

		void init_gi();

        void render_gi(RBCamera* camera);

        struct ID3D11Texture2D*			m_texture;
        struct ID3D11Texture2D*			m_textureGI;
        RBTexture*			            m_textureGI_cpu;
        RBTexture*			            m_textureGI_sh_cube;
        RBTexture*			            m_textureGI_sh_cpu_output;
        RBRenderTargetGroup*            m_gi_target;
        RBRenderTargetGroup*            m_gi_target_rgb8;
        RBRenderPassFullScreen*         m_fullscreen;
		IDirect3DDevice9Ex*				m_device;
        rb_private_members*             m_private_members;
        int                             pixels_visible;
	};
}
